<template>
	<view class="container">
		<view class="title pd_size">账号设置</view>
		<ConfigItem :dataList="userData" :disable="true"></ConfigItem>
		<view class="logOut flex">
			<button class="logOutTxt bg-color flex" @tap="logOut">退出登录</button>
		</view>
	</view>
</template>

<script>
	import {mapMutations,mapState} from "vuex"
	import ConfigItem from '@/components/my-config/my-config-item.vue'
	export default {
		data() {
			return {
				userData:[
					{
						title_type:'',
						title:'修改密码',
						info:'',
						tips:''
					}
				]
			}
		},
		computed:{
			...mapState({
				userInfo: state => state.user.userInfo
			})
		},
		components:{
			ConfigItem
		},
		onLoad() {
			let user = {
				title_type:'img',
				title:this.userInfo.imgUrl,
				info:this.userInfo.phone,
				tips:'编辑用户信息'
			}
			this.userData.unshift(user)
		},
		methods: {
			...mapMutations(['loginOut']),
			logOut(){
				uni.showModal({
					title:"提示",
					content:"确定退出登录吗？",
					success: (res) => {
						if(res.confirm){
							this.loginOut()
							uni.reLaunch({
								url:"/pages/index/index"
							}),
							uni.showToast({
								title:"退出成功",
								icon:"none"
							})
							// 清楚本地搜索词
							uni.removeStorage({
								key:"searchData"
							})
						}else {
							uni.showToast({
								title:"欢迎您的信任",
								icon:"none"
							})
						}
					}
				})
			},
			EditUser (){
				uni.navigateTo({
					url:'/pages/login-set-pwd/login-set-pwd?pageType='+'my'+''
				})
			}
		}
	}
</script>

<style scoped>
.container{
	padding: 6rpx;
}
.flex-sb{
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.pd_size {
	padding: 10rpx;
	font-size: 26rpx;
}
.flex{
	display: flex;
	justify-content: center;
	align-items: center;
}
.logOutTxt{
	position: fixed;
	bottom: 0%;
	left: 0%;
	width: 100%;
	height: 60rpx;
	font-size: 28rpx;
	color: white;
}
.title{
	padding: 10rpx;
	color: #b9b9b9;
}
.user_img{
	width: 80rpx;
	height: 80rpx;
	border-radius: 100%;
}
.img_tel{
	display: flex;
	justify-content: center;
	align-items: center;
}
.Edit_User{
	padding: 10rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.user_phone{
	font-size: 22rpx;
	margin-left: 16rpx;
}
.text{
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 22rpx;
	color: #b9b9b9;
}
</style>
